#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMouseEvent>
#include <QMimeData>
#include <tcpclient.h>
#include <tcpserver.h>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow() override;

private slots:
    void on_start_listen_btn_clicked();

    void on_server_send_btn_clicked();

    void on_client_connect_btn_clicked();

    void on_client_send_btn_clicked();

    void slotServerReadyread(TcpProtocol);

    void slotClientReadyread(TcpProtocol);

    void slotClientConnected();

    void slotClientDisconnected();

    void slotClientDisplayError(QAbstractSocket::SocketError);

    void on_server_file_send_btn_clicked();

    void on_client_file_send_btn_clicked();

signals:
    void serverInit();

    void clientInit();

    void startListen(QString , QString);

    void serverSendData(const QString & );

    void clientConnectTo(QString ip, QString port);

    void clientCloseConnect();

    void clientSendData(const QString & );

    void serverSendFile(const QString & filepath,int seek = 0 );

    void clientSendFile(const QString & filepath,int seek = 0 );
protected:
    void dragEnterEvent(QDragEnterEvent *event) override;
    void dropEvent(QDropEvent *event) override;
private:
    Ui::MainWindow *ui;
    TcpServer*  tcpServer;
    TcpClient*  tcpClient;
};
#endif // MAINWINDOW_H
